package org.tp8.sampleapp.loader.jobs.teacher.service.impl;

import org.springframework.stereotype.Service;
import org.tp8.sampleapp.loader.exc.SampleLoaderException;
import org.tp8.sampleapp.loader.jobs.teacher.model.TeacherCase;
import org.tp8.sampleapp.loader.jobs.teacher.service.intf.TeacherInputService;
import org.tp8.sampleapp.model.Teacher;

@Service
public class TeacherInputServiceImpl implements TeacherInputService {

	/** The count. */
	private static Long count = 0L;
	
	@Override
	public synchronized Long fetchNextCaseID() throws SampleLoaderException {
		if (count < 100) {
			count++;
		} else {
			return null;
		}
		return count;
	}

	@Override
	public TeacherCase loadTeacher(Long id) throws SampleLoaderException {

		Teacher teacher = new Teacher();
		teacher.setId(id);
		teacher.setFirstName("firstName" + id);
		teacher.setLastName("lastName" + id);

		TeacherCase teacherCase = new TeacherCase();
		teacherCase.setEntity(teacher);

		return teacherCase;
	}

}
